<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('修改主持人')" />
</head>
<body class="white-bg">
	<div class="wrapper wrapper-content animated fadeInRight ibox-content">
		<div class="wrapper wrapper-content animated fadeInRight ibox-content" >
			<form class="form-horizontal m" id="form-host-edit" th:object="${host}">
				<input id="hostId" name="hostId" type="hidden" th:field="*{hostId}"/>
				<div class="form-group">
					<label class="col-sm-3 control-label">姓名：</label>
					<div class="col-sm-8">
						<input class="form-control" type="text" name="hostName" id="hostName" required th:field="*{hostName}">
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-3 control-label ">手机号：</label>
					<div class="col-sm-8">
						<input class="form-control" type="text" name="hostPhone" id="hostPhone" required th:field="*{hostPhone}">
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-3 control-label">邮箱：</label>
					<div class="col-sm-8">
						<input class="form-control" type="text" name="hostEmail" id="hostEmail" required th:field="*{hostEmail}">
					</div>
				</div>
			</form>
	</div>
	<th:block th:include="include :: footer" />
	<script type="text/javascript">
		var prefix = ctx + "user/host";

		$("#form-post-add").validate({
			onkeyup: false,
			rules:{
				hostPhone:{
					remote: {
						url: prefix + "/checkHostPhone",
						type: "post",
						dataType: "json",
						data: {
							"hostPhone" : function() {
								return $.common.trim($("#hostPhone").val());
							}
						},
						dataFilter: function(data, type) {
							return $.validate.unique(data);
						}
					}
				},
				hostEmail:{
					remote: {
						url: prefix + "/checkHostEmail",
						type: "post",
						dataType: "json",
						data: {
							"hostEmail" : function() {
								return $.common.trim($("#hostEmail").val());
							}
						},
						dataFilter: function(data, type) {
							return $.validate.unique(data);
						}
					}
				},
				postSort:{
					digits:true
				},
			},
			messages: {
				"hostPhone": {
					remote: "手机号已经存在"
				},
				"hostEmail": {
					remote: "邮箱已经存在"
				}
			},
		    focusCleanup: true
		});
		
		function submitHandler() {
	        if ($.validate.form()) {
	        	$.operate.save(prefix + "/edit", $('#form-host-edit').serialize());
	        }
	    }
	</script>
</body>
</html>
